package com.zd.room.service.impl;

import java.util.List;
import java.util.UUID;

import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.SysUser;
import com.zd.room.vo.RoomVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zd.room.mapper.RoomMapper;
import com.zd.room.domain.Room;
import com.zd.room.service.RoomService;
import com.ruoyi.common.core.text.Convert;

/**
 * 户Service业务层处理
 * 
 * @author fxiao
 * @date 2020-08-12
 */
@Service
public class RoomServiceImpl implements RoomService
{
    @Autowired
    private RoomMapper roomMapper;

    /**
     * 查询户
     * 
     * @param id 户ID
     * @return 户
     */
    @Override
    public Room selectRoomById(String id)
    {
        return roomMapper.selectRoomById(id);
    }

    @Override
    public RoomVo selectRoomVoById(String id) {
        return roomMapper.selectRoomVoById(id);
    }

    /**
     * 查询户列表
     * 
     * @param room 户
     * @return 户
     */
    @Override
    public List<Room> selectRoomList(Room room)
    {
        return roomMapper.selectRoomList(room);
    }

    @Override
    public List<RoomVo> selectRoomVoList(RoomVo roomVo) {
        return roomMapper.selectRoomVoList(roomVo);
    }

    /**
     * 新增户
     * 
     * @param room 户
     * @return 结果
     */
    @Override
    public int insertRoom(Room room)
    {
        room.setId(UUID.randomUUID().toString().replaceAll("-",""));
        return roomMapper.insertRoom(room);
    }

    @Override
    public int insertRoomList(List<Room> roomList) {
        return roomMapper.insertRoomList(roomList);
    }

    /**
     * 修改户
     * 
     * @param room 户
     * @return 结果
     */
    @Override
    public int updateRoom(Room room)
    {
        SysUser sysUser= ShiroUtils.getSysUser();
        room.setUpdateBy(sysUser.getLoginName());
        return roomMapper.updateRoom(room);
    }

    /**
     * 删除户对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteRoomByIds(String ids)
    {
        return roomMapper.deleteRoomByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除户信息
     * 
     * @param id 户ID
     * @return 结果
     */
    @Override
    public int deleteRoomById(String id)
    {
        return roomMapper.deleteRoomById(id);
    }

    @Override
    public int deleteRoomBySsjzId(String ssjzId) {
        return roomMapper.deleteRoomBySsjzId(ssjzId);
    }
}
